namespace _RobotInspection.Models
{
    public class ApiResponse<T>
    {
        public int Code { get; set; }
        public string? Message { get; set; }
        public T Data { get; set; }
        public long TotalCount { get; set; } // 分页总条数

        public static ApiResponse<T> Success(T data, string? message="操作成功", long totalCount = 0)
        {
            return new ApiResponse<T>
            {
                Code = 200,
                Message = message,
                Data = data,
                TotalCount = totalCount
            };
        }

        public static ApiResponse<T> Error(string message = "操作失败", int code = 500)
        {
            return new ApiResponse<T>
            {
                Code = code,
                Message = message,
                Data = default
            };
        }
    }
}